package org.siva.sivaprasanna;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 * Servlet implementation class SimpleServlet
 */
public class SimpleServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		//System.out.println("hello this is get method ");
		response.setContentType("text/html");
		PrintWriter out=response.getWriter();
		String username=request.getParameter("user name");
		HttpSession session=request.getSession();
		ServletContext context=request.getSession().getServletContext();
		if(username!="" && username !=null){
			session.setAttribute("savedusername",username);
			context.setAttribute("savedusername", username);
		}
		//request.getAttribute(username);
		out.println("request parameter user as : "+username);
		out.println("session parameter username as "+(String) session.getAttribute("savedusername"));
		out.println("context parameter username as "+(String) context.getAttribute("savedusername"));		
	}

}
